package com.example.lxj.system.controller;

import com.example.lxj.base.annoation.NoNeedLogin;
import com.example.lxj.base.entity.AjaxRes;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/common")
public class CommonController {

    @Autowired
    private FileStorageService fileStorageService;

    /**
     * 上传文件
     */
    @PostMapping("/upload")
    @NoNeedLogin
    public AjaxRes upload(@RequestParam("file") MultipartFile file) {
        return AjaxRes.success(fileStorageService.of(file).upload());
    }
}
